<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>Document</title>

	<style>
		.box{
			width:100px;
			height: 100px;
			background-color:pink;
		}
	</style>
</head>

<body>
	<input type="button" value="设置值" id="btn">
	<div class="box" id="box">你好</div>

	<script>
		var boxObj = document.getElementById('box')

		btn.onclick = function () {
			boxObj.innerText = "我是一个盒子"

			// boxObj.innerHTML= "我是一个盒子"
			//ie8不支持textContent这个属性
			// boxObj.textContent= "我是一个盒子"

		}
	</script>
</body>

</html>